function [acc] = lracc(sc_type, alpha, refvar, maxev, minev)

% LRACC Compute the "acceleration factor": the ratio between
% the time scales in two adjacent limiting regimes, see LRSCALES. 
%
% The acceleration factor should be chosen as large as possible but
% not too large to be able to observe a sufficient number of events
% in the common time window. We choose here the smallest and
% largest number of events to be contained in the same window and
% then compute the ratio.
%
% Consider a process {X(t), 0<=t<=T} in three time scales a1<a2<a3
% corresponding to the three limit regimes. We have
% a2=m^(1/(alpha-1)), a1=a2/epsilon, a3=a2*epsilon, where epsilon>1 is
% the acceleration factor. We are interested in X(a1*t), X(a2*t),
% X(a3*t) in the interval [0,T3], where T3=T/a3.
%
% Given the scale a2 and two numbers N1<=N3, we compute epsilon so
% that the paths X(a1*t) and X(a3*t) in [0,T3] would contain
% approximately N1 and N3 points. If the expected number of points in
% {X(t), 0<=t<=T3} is linear in time, then roughly N3/N2=a3/a2,
% N2/N1=a2/a1. We have a3/a2=a2/a1=epsilon. Hence N2=sqrt(N1*N3)
% (geometric mean) and epsilon = sqrt(N3/N1).
%
% In the case of two time scales the calculations are analogous.
%
% [acc] = lracc(sc_type, alpha, refvar, maxev, minev)
% 
% Inputs:
%        sc_type - type of scaling: 1-fBm, 2-Intermediate, 3-Levy
%          motion, can be a vector containing combinations of the
%          above 
%        alpha - tail parameter of the sojourn distribution:
%          normalized Pareto, 1<alpha<=2
%        refvar - reference variable; number of processes
%          superposed in the models of superposition of renewal
%          processes and integrated sum of on-off processes,
%          arrival intensity in the infinite source Poisson model.
%        maxev - maximal number of events to be contained in the
%          time window.
%        minev - minimal number of events to be contained in the
%          time window. Optional, if NaN then computed
%          automatically.
%
% Outputs:
%        acc - the acceleration factor (scalar) 

% Authors: R.Gaigalas, I.Kaj
% v1.0 17-Dec-05

  nout = length(sc_type);

  if (nout == 1)
    acc = refvar^(0.7/(alpha-1));      
  elseif (nout == 2) & (~isempty(find(sc_type==2)))
    if isnan(minev) % set minimal number of events 
%      minev = min(max(500, 0.01*maxev), 0.5*maxev);
      minev = min(500, 0.5*maxev);    
    end
    acc = maxev/minev;
  else
    if isnan(minev) % set minimal number of events       
%      minev = min(max(200, 0.01*maxev), 0.5*maxev);
      minev = min(200, 0.5*maxev);      
    end
    acc = (maxev/minev)^0.5;       
  end
  
   

